﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Kristall.Engine;
using Kristall.Engine.Behaviors;

namespace Kristall.MyGame.Behaviors
{
    class ChaseBehavior : Behavior
    {
        public AABB Target { get; set; }


        public float Range { get; set; }
        
        public ChaseBehavior(NPC npc,AABB target) : base(npc)
        {
            Target = target;

            Range = 500;
        }

        public override void Update(float dt)
        {
            float distance = Vector2.Distance(NPC.Position, Target.Position);
            NPC.Movement = Vector2.Zero;

            if (distance > Range)
                return;


            Vector2 direction = Target.Position - NPC.Position;
            direction.Normalize();

            NPC.Movement = direction;


            base.Update(dt);
        }


        
    }
}
